/*
 * @Author: your name
 * @Date: 2020-12-14 16:37:50
 * @LastEditTime: 2021-06-16 18:07:12
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \qdBillingSystem\src\main.js
 */
import Vue from 'vue'
import App from './App.vue'
import echarts from 'echarts'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import axios from 'axios'
import http from './http'
import { download } from './http' // ------------下载
import { downloadlink } from './http' // ------------下载
import { judgeIsNum } from './http' // ------------规定必须是数字
import router from './router/index'
import store from './store/index'
import apiFetch from './api/apiFetch.js'

// 全局挂载 VueQuillEditor富文本
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.use(VueQuillEditor)
// 表格样式、类型
import 'xe-utils'
import VXETable from 'vxe-table'
import 'vxe-table/lib/index.css'
// 地址联动
import VueAreaLinkage from 'vue-area-linkage'
import VueClipboard from 'vue-clipboard2'
VueClipboard.config.autoSetContainer = true
Vue.use(VueClipboard)
// 图片预览
import VueDirectiveImagePreviewer from 'vue-directive-image-previewer'
import tabar from '@/components/tabar.vue'
import { CountDown } from 'vant'
Vue.use(CountDown)

// 表格横向滚动条
import horizontalScroll from 'el-table-horizontal-scroll'
Vue.use(horizontalScroll)

import './assets/styles/style.css' // VueDirectiveImagePreviewer图片样式
require('es6-promise').polyfill()
import '@babel/polyfill'
String.prototype.replaceAll = function (s1, s2) {
  return this.replace(new RegExp(s1, 'gm'), s2)
}

Vue.use(VueDirectiveImagePreviewer, {
  background: {
    // or : background: '#000'
    color: '#000' // or rgba or rgb     // or image: 'url(xxx)'
  },
  // transition
  animate: {
    duration: 600,
    delay: 500
  },
  loading: {
    image: ''
  },
  cursor: 'pointer',
  clickMethod: 'doubleClick' // click or doubleClick(not supported)
})
// 图片预览
import './assets/styles/variable.scss'
import './assets/styles/base.scss'
import './assets/styles/common.scss'
import './assets/styles/iconfont.css'
import './assets/styles/themes.scss'
import moment from 'moment' // 导入模块
moment.locale('zh-cn') // 设置语言 或 moment.lang('zh-cn');
Vue.prototype.$moment = function (e) {
  return moment(e).format('yyyy-MM-DD HH:mm:ss')
} // 赋值使用
Vue.prototype.$momentTwo = function (e) {
  return moment(e).format('yyyy-MM-DD')
} // 赋值使用
Vue.config.productionTip = false
Vue.prototype.$echarts = echarts
Vue.prototype.axios = http
Vue.prototype.download = download
Vue.prototype.judgeIsNum = judgeIsNum// 判断是否全是数字
Vue.prototype.https = 'http://120.25.194.154:8087'
Vue.prototype.ImgHttps = 'https://fenxiao.muruji.com/'
Vue.prototype.downloadlink = downloadlink

Vue.prototype.$api = apiFetch

// 输入框只能输入数字且限制长度时使用
// oninput="if (value.length > 30) value = value.slice(0, 30);"
Vue.directive('enterNumber', {
  inserted: function (el) {
    el.addEventListener('keypress', function (e) {
      e = e || window.event
      const charcode = typeof e.charCode === 'number' ? e.charCode : e.keyCode
      const re = /\d/
      if (!re.test(String.fromCharCode(charcode)) && charcode > 9 && !e.ctrlKey) {
        if (e.preventDefault) {
          e.preventDefault()
        } else {
          e.returnValue = false
        }
      }
    })
  }
})

// 用于lb-tabel组件无法将html格式数据回显
Vue.directive('exchangeHtml', {
  bind: function (el, foo) {
    console.log(el, foo, 'el,foo')
    el.innerHTML = foo.value
  }
})

Vue.use(VXETable)
Vue.use(ElementUI)
Vue.use(VueAreaLinkage)
Vue.component('tarbar', tabar)

if (process.env.NODE_ENV !== 'development') { // process是Node环境全部变量, 运行时根据敲击的命令不同, 脚手架会取环境变量给env添加属性和值
  console.log = function () {}
  console.error = function () {}
  console.dir = function () {}
}

new Vue({
  render: (h) => h(App),
  router,
  store
}).$mount('#app')
